package com.example.demo;

import org.noear.solon.annotation.Component;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.annotation.Param;
import org.noear.solon.annotation.Post;
import org.noear.solon.core.handle.ModelAndView;
import org.noear.solon.core.handle.UploadedFile;

/**
 * @author airhead
 */
@Component(tag = "admin")
@Mapping("demo")
// @Controller
public class DemoController {
  @Mapping("/hello")
  public String hello(@Param(defaultValue = "world") String name) {
    return String.format("Hello %s!", name);
  }

  @Mapping("/hello2")
  public ModelAndView hello2(@Param(defaultValue = "world") String name) {
    return new ModelAndView("test.shtm").put("name", name);
  }

  @Mapping("/sub")
  public ModelAndView sub() {
    return new ModelAndView("sub.shtm");
  }

  @Mapping("/upload")
  @Post
  public String upload(UploadedFile file) {
    return "ok";
  }
}
